// -----------------------------------------------------------------------
//  <copyright file="OrganizationConfiguration.cs" company="LiuliuSoft">
//      Copyright (c) 2022-2024 DaprPlus. All rights reserved.
//  </copyright>
//  <site>https://dapr.plus</site>
//  <last-editor>郭明锋</last-editor>
//  <last-date>2024/12/10 20:01:37</last-date>
// -----------------------------------------------------------------------

using Liuliu.Fsb.Services.Identity.Domain.Entities;


namespace Liuliu.Fsb.Services.Identity.Infrastructure.EntityFrameworkCore.Configurations;

public class OrganizationConfiguration : EntityConfigurationBase<Organization>
{
    /// <summary>
    /// 配置类型的实体
    /// </summary>
    /// <param name="builder">用于配置实体类型的构建器。</param>
    public override void Configure(EntityTypeBuilder<Organization> builder)
    {
        builder.HasOne<Organization>().WithMany(n => n.Children).HasForeignKey(m => m.ParentId).IsRequired(false);
        builder.HasMany(m => m.Users).WithMany(n => n.Organizations);
    }
}
